var popupStatus = 0;

function loadPopup() {
    if (popupStatus == 0) {
        $("#backgroundPopup").css({
            "opacity": "0.7"
        });
        $("#backgroundPopup").fadeIn("slow");
        $("#popupContact").fadeIn("slow");
        popupStatus = 1
    }
}
function disablePopup() {
    if (popupStatus == 1) {
        $("#backgroundPopup").fadeOut("slow");
        $("#popupContact").fadeOut("slow");
        popupStatus = 0
    }
}
function centerPopup() {
    var a = document.documentElement.clientWidth;
    var b = document.documentElement.clientHeight;
    var c = $(window).scrollTop() + $("#popupContact").height();
    var d = $("#popupContact").width();
    $("#popupContact").css({
        "position": "fixed",
        "top": ($(window).scrollTop() + b) / 2 - c / 2,
        "left": a / 2 - d / 2
    });
    $("#backgroundPopup").css({
        "height": b
    })
}
$(document).ready(function () {
    $("#backgroundPopup").click(function () {
        disablePopup()
    });
    $(document).keypress(function (e) {
        if (e.keyCode == 27 && popupStatus == 1) {
            disablePopup()
        }
    })
});



function loadPopup(popform, backpopupform) {
    
    if (popupStatus == 0) {
        $(backpopupform).css({
            "opacity": "0.7"
        });
        $(backpopupform).fadeIn("slow");
        $(popform).fadeIn("slow");
        popupStatus = 1
    }
}
function disablePopup(popform,backpopupform) {
    if (popupStatus == 1) {
        $(backpopupform).fadeOut("slow");
        $(popform).fadeOut("slow");
        popupStatus = 0
    }
}
function centerPopup(popform,backpopupform) {
    var a = document.documentElement.clientWidth;
    var b = document.documentElement.clientHeight;
    var c = $(window).scrollTop() + $(popform).height();
    var d = $(popform).width();
    $(popform).css({
        "position": "fixed",
        "top": ($(window).scrollTop() + b) / 2 - c / 2,
        "left": a / 2 - d / 2
    });
    $(backpopupform).css({
        "height": b
    })
}